<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UploadController extends Controller
{
    public function upload(Request $request){
    	//判断是否为合法文件
		$file=$request->file('file');
		if($file->isValid ()){
			$path=$file->store (date ('ymd'),'upload');
			return ['file' => asset('uploadImages/'.$path), 'code' => 0];
		}else{
			return ['message' => '上传失败', 'code' => 403];
		}
	}
	public function editUpload(Request $request){
		//判断是否为合法文件
		$file=$request->file('file');
		if($file->isValid ()){
			$path=$file->store (date ('ymd'),'upload');
			return [
				"success"   => true,
				"msg"       => "上传成功",
				"file_path" => asset('uploadImages/'.$path)//文件地址
			];
		}
	}
}
